package com.amos.base.wrapper;

import lombok.Data;

@Data
public class Result {
    /**
     * 业务成功
     */
    public static final int RESULT_SUCCESS = 1;
    /**
     * 业务验证失败
     */
    public static final int RESULT_VALIDATEERROR = 2;
    /**
     * 业务出错
     */
    public static final int RESULT_ERROR = -1;
    /**
     * 业务成功默认返回信息
     */
    public static final String DEFAULT_MSG = "ok";
    /**
     * 业务出错默认返回信息
     */
    public static final String DEFAULT_ERROR = "系统出现异常，请联系管理员";
    /**
     * 返回的数据
     */
    public Object data;
    /**
     * 返回的状态码
     */
    private int code;
    /**
     * 返回的信息
     */
    private String msg;

    /**
     * 无参构造器
     */
    public Result(Result.Builder builder){
        this.code  = builder.code;
        this.msg = builder.msg;
        this.data = builder.data;
    }

    public static class Builder{
        private int code;
        private String msg;
        private Object data;
        public Builder(int code){
            this.code = code;
        }

        public Result.Builder msg(String msg){
            this.msg = msg;
            return this;
        }

        public Result.Builder data (Object data){
            this.data = data;
            return this;
        }

        public Result builder(){
            return new Result(this);
        }
    }


}
